<?php
/**
 * System_Model_Employee
 *
 * @author mmxie
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: Employee.php 1082 2011-12-09 09:27:48Z mmxie $
 */
class System_Model_Employee extends IG_Model
{

    protected $_data = array(
        'employee_id' => null,
        'department_id' => null,
        'name' => null,
        'password' => null,
        'passpod' => null,
        'real_name' => null,
        'email' => null,
        'last_login' => null,
        'last_error' => null,
        'error_times' => null,
        'status' => null,
    );

    protected $_roles;

    /**
     * @param int $value
     * @return System_Model_Employee
     */
    public function setEmployeeId($value)
    {
        $this->employee_id = (int) $value;
        return $this;
    }

    public function getEmployeeId()
    {
        return $this->employee_id;
    }

    /**
     * @param int $value
     * @return System_Model_Employee
     */
    public function setDepartmentId($value)
    {
        $this->department_id = (int) $value;
        return $this;
    }

    public function getDepartmentId()
    {
        return $this->department_id;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setName($value)
    {
        $this->name =  $value;
        return $this;
    }

    public function getName()
    {
        return $this->name;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setPassword($value)
    {
        $this->password =  $value;
        return $this;
    }

    public function getPassword()
    {
        return $this->password;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setPasspod($value)
    {
        $this->passpod =  $value;
        return $this;
    }

    public function getPasspod()
    {
        return $this->passpod;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setRealName($value)
    {
        $this->real_name =  $value;
        return $this;
    }

    public function getRealName()
    {
        return $this->real_name;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setEmail($value)
    {
        $this->email =  $value;
        return $this;
    }

    public function getEmail()
    {
        return $this->email;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setLastLogin($value)
    {
        $this->last_login =  $value;
        return $this;
    }

    public function getLastLogin()
    {
        return $this->last_login;
    }

    /**
     * @param string $value
     * @return System_Model_Employee
     */
    public function setLastError($value)
    {
        $this->last_error =  $value;
        return $this;
    }

    public function getLastError()
    {
        return $this->last_error;
    }

    /**
     * @param int $value
     * @return System_Model_Employee
     */
    public function setErrorTimes($value)
    {
        $this->error_times = (int) $value;
        return $this;
    }

    public function getErrorTimes()
    {
        return $this->error_times;
    }

    /**
     * @param int $value
     * @return System_Model_Employee
     */
    public function setStatus($value)
    {
        $this->status = (int) $value;
        return $this;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function getRoles($id = null)
    {
        if (!isset($this->_roles)) {
            $id = is_null($id) ? $this->getEmployeeId() : $id;
            $this->_roles = $this->getMapper()->getRoles($id);
            $this->_mapper = null; //登录时 mapper不存SESSION
        }
        return $this->_roles;
    }

    public function loginError($name) {
        return $this->getMapper()->loginError($name);
    }
}